Telegram Group & Telegram Channel
Аннотации типов: Union и Optional

Ранее на канале был пост про базовые аннотации типов. Но важно знать и про такие аннотации, как Union и Optional.

При необходимости допустить использование не любых типов, а только некоторых, можно использовать аннотацию Union[T, ...] с указанием списка типов в квадратных скобках.

Для объявления опциональных переменных используется Optional[T]. Такая аннотация нужна для переменных, которые либо имеют значение определенного типа, либо равны None.

Кстати, аннотация Optional[T] эквивалентна Union[T, None].

#аннотации



tg-me.com/python_academy/943
Create:
Last Update:

Аннотации типов: Union и Optional

Ранее на канале был пост про базовые аннотации типов. Но важно знать и про такие аннотации, как Union и Optional.

При необходимости допустить использование не любых типов, а только некоторых, можно использовать аннотацию Union[T, ...] с указанием списка типов в квадратных скобках.

Для объявления опциональных переменных используется Optional[T]. Такая аннотация нужна для переменных, которые либо имеют значение определенного типа, либо равны None.

Кстати, аннотация Optional[T] эквивалентна Union[T, None].

#аннотации

BY Python Academy




Share with your friend now:
tg-me.com/python_academy/943

View MORE
Open in Telegram


Python Academy Telegram | DID YOU KNOW?

Date: |

Export WhatsApp stickers to Telegram on iPhone

You can’t. What you can do, though, is use WhatsApp’s and Telegram’s web platforms to transfer stickers. It’s easy, but might take a while.Open WhatsApp in your browser, find a sticker you like in a chat, and right-click on it to save it as an image. The file won’t be a picture, though—it’s a webpage and will have a .webp extension. Don’t be scared, this is the way. Repeat this step to save as many stickers as you want.Then, open Telegram in your browser and go into your Saved messages chat. Just as you’d share a file with a friend, click the Share file button on the bottom left of the chat window (it looks like a dog-eared paper), and select the .webp files you downloaded. Click Open and you’ll see your stickers in your Saved messages chat. This is now your sticker depository. To use them, forward them as you would a message from one chat to the other: by clicking or long-pressing on the sticker, and then choosing Forward.

Telegram today rolling out an update which brings with it several new features.The update also adds interactive emoji. When you send one of the select animated emoji in chat, you can now tap on it to initiate a full screen animation. The update also adds interactive emoji. When you send one of the select animated emoji in chat, you can now tap on it to initiate a full screen animation. This is then visible to you or anyone else who's also present in chat at the moment. The animations are also accompanied by vibrations. This is then visible to you or anyone else who's also present in chat at the moment. The animations are also accompanied by vibrations.

Python Academy from sa


Telegram Python Academy
FROM USA